<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<%=basePath%>static/css/jquery-ui.min.css" />
<link href="<%=basePath%>static/css/common_css.css" rel="stylesheet" />
<script type="text/javascript"
	src="<%=basePath%>static/js/jquery-1.11.1.min.js"></script>
<title>付款</title>
<script type="text/javascript">
	$(function(){
		$("#payButton").click(function(){
			var total = $("#totalPrice").val();
			$.ajax({
				url:"<%=basePath%>users/checkAccountNo",
				type:"post",
				data:{totalPrice:total},
				success:function(result){
					if(result) {
						$.ajax({
							url:"<%=basePath%>order/payOrder",
							type:"post",
							data:{orderId:$("#orderId").val()},
							success:function(data){
								if(data) {
									alert("付款成功");
									$("#payDiv").css("display","none");
									$("#paySuccess").css("display","");
								} else {
									alert("付款失败");
								}
							}
						});
					} else {
						alert("余额不足，请先充值");
						window.location.href="<%=basePath%>users/toAccount";
					}
				}
			})
		});
		$("#cancelButton").click(function(){
			if(confirm("是否要取消该笔订单？")){
				$.ajax({
					url:"<%=basePath%>order/cancelOrder",
					data:{orderId:$("#orderId").val()},
					type:"post",
					success:function(data){
						if(data){
							alert("订单取消成功！请重新预订车票");
							window.location.href="<%=basePath%>order/searchTickets";
						}else{
							alert("订单取消失败！");
						}
					}
				});
			}
		});
	})
</script>
</head>
<body>
<!--header start-->
<div class="header"><div style="z-index: 2000" class="header-bd">
<a href="<%=basePath %>login/index"><h1 class="logo">票务中心</h1>
</a>
<div class="login-info"><div class="phone-link">
</div>
<div class="menu">
</div>
<span class="login-txt" style="color: #666666"><span>意见反馈:12345@163.com </span>
<c:if test="${sessionScope.user!=null }">
<span style="width:50px;">${sessionScope.user.userName }</span>
| <a id="regist_out" href="<%=basePath %>login/loginOut">退出</a>
</c:if>
<c:if test="${sessionScope.user==null }">
请
<a id="login_user" href="<%=basePath %>login/toLogin" class="colorA" style="margin-left:-0.5px;">登录</a>
|<a id="regist_out" href="<%=basePath %>login/toRegister">注册</a>
</c:if>
</span>
</div>
<div class="nav"><ul><li><a href="<%=basePath %>login/index">客运首页</a>
</li>
<li id="selectYuding"><a href="<%=basePath %>order/searchTickets"  >车票预订</a>
</li>

<li><a href="<%=basePath %>ticket/searchTicketsByCon" target="_blank">车次查询</a>
</li>
<li><a href="<%=basePath %>ticket/searchTicketsByCon" target="_blank">票价查询</a>
</li>
<li><a href="<%=basePath %>ticket/searchTicketsByCon" target="_blank">站点查询</a>
<c:if test="${sessionScope.user!=null }">
<li ><a href="<%=basePath %>login/main">个人中心</a>
</li>
</c:if>
</ul>
</div>
</div>
</div>
	<!--header end-->
	<!--页面主体  开始-->
<div class="content" id="main_content" style="min-height: 830px;"><!--支付提示 开始-->
<div class="t-succ t-lock"><div class="pay-tips"><span class="i-lock"></span>
<h3><span>
			席位已锁定，请在<span class="colorA">30</span> 分钟内进行支付，完成网上购票。
			 <!-- <span>支付剩余时间：<strong id="ShowTime" class="colorA"><strong>29分27秒</strong></strong></span> -->
</span>
</h3>
</div>
</div>
<!--订单信息 开始-->
<div class="layout b-info">
<div class="lay-hd">订单信息</div>
<div class="lay-bd"><div class="info" id="show_title_ticket">
<input type="hidden" value="${orderHeader.orderId}" id="orderId">
<strong class="mr5"><fmt:formatDate value="${orderHeader.orderDate }" pattern="yyyy-MM-dd"/> </strong> 
<strong class="mr5">${orderHeader.ticket.ticketNo } 次 </strong> 
<strong class="ml5">${orderHeader.ticket.startStation }</strong>站<strong>
（<fmt:formatDate value="${orderHeader.startTime }" pattern="HH:mm:ss"/>开）—${orderHeader.ticket.endStation }</strong>站
</div>
<table class="table-a" id="table_list">
<tbody><tr>
<th rowspan="1" colspan="1" width="20%"><strong>序号</strong></th>
<th rowspan="1" colspan="1" width="25%"><strong>姓名</strong></th>
<th rowspan="1" colspan="1" width="30%"><strong>证件号码</strong></th>
<th rowspan="1" colspan="1" width="25%"><strong>票价（元）</strong></th>
</tr>
</tbody>
<tbody id="show_ticket_message">
<c:forEach items="${orderHeader.orderDetail}" var="detail" varStatus="index">
	<tr>
		<td align="center">${index.count }</td>
		<td>${detail.passenger.passengerName }</td>
		<td>${detail.passenger.cardNo }</td>		
		<td>${detail.orderPrice }元</td>
	</tr>

</c:forEach>
</tbody>
</table>
</div>
<div class="total-box"><div class="item">总票价：<span class="price" id="total_ticket_price">${orderHeader.orderPrice } 元</span>
</div>
</div>
<div class="lay-btn bt_blue">
<p id="payDiv"><a href="javascript:void(0);" class="btn92" id="cancelButton" shape="rect">取消订单</a>
<span>
<a href="javascript:void(0);" class="btn92s" id="payButton" shape="rect">网上支付</a>
<input type="hidden" id="totalPrice" value="${orderHeader.orderPrice } " />
</span>
</p>
<p id="paySuccess" style="display: none;font-size: 60px;color: red;">支付成功</p><!-- 跳转到订单成功页面 -->
</div>
</div>
</div>

<!--订单信息 结束-->
	<!--页面主体  结束-->
	<!--页面底部  开始-->
	<div class="footer">
		<p>
			<a href="javascript:void(0);" >关于我们</a>
			|<a href="javascript:void(0);" >网站声明</a>
		</p>
		<p>版权所有 © 2008-2017 中国铁路信息技术中心 中国铁道科学研究院</p>
		<p>京ICP备15003716号-3&nbsp;&nbsp;|&nbsp;&nbsp;京ICP证150437号</p>
	</div>
	<!--页面底部  结束-->
</body>
</html>